<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>新建简历</title>
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="css/validator.css" />
<link rel="stylesheet" href="css/howitworks.css" />
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/pixie.css" />

<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>

<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="js/jquery.ui.button.js"></script>
<script type="text/javascript" src="js/jquery.ui.position.js"></script>

<script type="text/javascript" src="js/formValidator.js"></script>
<script type="text/javascript" src="js/formValidatorRegex.js"></script>
<script type="text/javascript" src="js/DateTimeMask.js"></script>

<script type="text/javascript">

window.onbeforeunload = function()
{
	if(Math.abs(event.clientX - document.body.clientWidth) < 30)
	{
		if (confirm('确实要退出简历管理？'))
			window.location.href("login.action");
		else
			event.returnValue = '请点取消留在本页面！';
	}
}

function init() {
    document.body.oncontextmenu=function(){return false;}
}

function click()   {                                                                                                                             
	if(event.ctrlKey && event.keyCode == 67)   {                                                                                                                     
		return false;                                                          
	}                                                                                                                                                               
}                                                                                                                                                               
document.onkeydown=click;

$(document).ready(function() {
			init();
				initElement();
				
				var result = document.getElementById("result").value;
				if (result == 1) {
					alert("提交成功")
				} else if (result == 2) {
					alert("提交失败, 用户名重复")
				}
	});
	
	function initElement() {
		$("#submitResume").button();
		
		$.formValidator.initConfig({formid:"user-create",onerror:function(msg){alert(msg)},onsuccess:function(){return false;}});
		$("#name").formValidator({
			onshow:"请输入用户名",
			onfocus:"用户名不能为空"})
			.inputValidator({
				min:1,
				onerror:"用户名不能为空,请确认"});
		$("#password1").formValidator({
			onshow:"请输入密码",onfocus:"密码不能为空",oncorrect:"密码合法"}).inputValidator({min:1,empty:{leftempty:false,rightempty:false,emptyerror:"密码两边不能有空符号"},onerror:"密码不能为空,请确认"});

		$("#password2").formValidator({
			onshow:"请输入重复密码",
			onfocus:"两次密码必须一致",
			oncorrect:"密码一致"}).inputValidator({min:1,empty:{leftempty:false,rightempty:false,emptyerror:"重复密码两边不能有空符号"},onerror:"重复密码不能为空,请确认"}).compareValidator({desid:"password1",operateor:"=",onerror:"2次密码不一致,请确认"});
		
		$("#password1").val("");
		$("#password2").val("");
	}
	
	function submitInfo() {
		var name = document.getElementById("name").value;
		var password1 = document.getElementById("password1").value;
		var password2 = document.getElementById("password2").value;
		
		if (name == null || name == "") {
			alert("用户名不能为空");
		} else if (password1 == null || password1 == "") {
			alert("密码不能为空");
		} else if (password2 == null || password2 == "" || password2 != password1) {
			alert("两次密码必须一致");
		} else {
			document.getElementById("isCreateUser").value = 1;
			document.getElementById("user-create").submit();
		}
	}
	
</script>
</head>
<body bgcolor="#ECF5FF">
<div class="top_bar">
	<ul class="nav">
		<li><span class="SayHi">欢迎: 
			<%=session.getAttribute("username")%>
		</span>
		</li>
		<li id="search">
			<a href="/resume/resume-main.action?page=0&pageSize=10">返回首页</a>
		</li>
		<li id="search">
			<a href="/resume/resume-list.action">搜索简历</a>
		</li>
		<li id="createResume">
			<a href="/resume/resume-insert.action">新建简历</a>
		</li>
		<li id="managerResume">
			<a href="/resume/resume-manager.action">简历管理</a>
		</li>
		<li id="userList">
			<a href="/resume/user-list.action">用户列表</a>
		</li>
		<li id="userList">
			<a href="/resume/audit-list.action?page=0&pageSize=20">日志</a>
		</li>
		<li>
			<a href="/resume/login.action">退出</a>
		</li>
	</ul>
</div>
	<div class="main">
  <div class="wrap_top"></div>
  <div class="wrap_l_r l_r_left_insert">
    <div class="wrap_right">
    	<s:form id="user-create" action="user-create" method="post">
			<div>
				<table width="100%" border="0" align="left" cellpadding="0" align="center"
					cellspacing="0">
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td><label>姓&nbsp;&nbsp;名:</label></td>
						<td><s:textfield id="name" class="date-pick" theme="simple" cssClass="input_a"
								label="姓名" name="user.userName" size="35" /></td>
						<td>
							<div id="nameTip" style="width:200px"></div>
						</td>
					</tr>
					<tr>
						<td><label>密&nbsp;&nbsp;码:</label></td>
						<td><s:textfield class="date-pick" id="password1" theme="simple" label="密码" name="user.password" cssClass="input_a"
								size="35" /></td>
						<td>
							<div id="password1Tip" style="width:200px"></div>
						</td>
					</tr>
					<tr>
						<td><label>确认密码:</label></td>
						<td><s:textfield class="date-pick" id="password2" theme="simple" label="确认密码" cssClass="input_a"
								size="35" /></td>
						<td>
							<div id="password2Tip" style="width:200px"></div>
						</td>
					</tr>
					<tr>
						<td>&nbsp;
						<s:hidden id="user.id" name="user.id" />
						</td>
					</tr>
				</table>
				<div><h3>权限设置:</h3></div>
				<table width="20%" border="0" align="left" cellpadding="0" align="center"
					cellspacing="0">
					<tr>
						<td>
							<s:checkbox name="permLevel.createResume" label="新建简历" />
						</td>
						<td>
							<s:checkbox name="permLevel.editResume" label="编辑简历"/>
						</td>
						<td>
							<s:checkbox name="permLevel.deleteResume" label="管理简历"/>
						</td>
						<td>
							<s:checkbox name="permLevel.surperSearch" label="超级搜索"/>
						</td>
						<td>
							<s:checkbox name="permLevel.createXls" label="下载excel"/>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</table>
				<table width="20%" border="0" align="left" cellpadding="0" align="center"
					cellspacing="0">
					<tr>
						<td>
							<s:checkbox name="permLevel.createUser" label="新建用户" />
						</td>
						<td>
							<s:checkbox name="permLevel.editUser" label="编辑用户"  />
						</td>
						<td>
							<s:checkbox name="permLevel.deleteUser" label="用户管理" />
						</td>
						<td>
							<s:checkbox name="permLevel.sysManager" label="系统管理" />
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</table>
				<table width="100%" border="0" align="left" cellpadding="0" align="center"
					cellspacing="0">
					<tr>
						<td colspan="2">
							<div align="left">
								<input type="button" id="submitResume" value="提交用户信息" onclick="submitInfo()"/>
							</div>
						</td>
					</tr>
				</table>
				<s:hidden id="isCreateUser" name="isCreateUser" />
			</div>
		</s:form>
    </div>
  </div>
  <div class="clear"></div>
  <div class="wrap_bottom"></div>
  <s:hidden id="result" name="result" />
</div>
</body>
</html>